package work20241228;

import java.util.ArrayList;

/**
 * @author zdl
 * @date 2024/12/28
 */
class Employee{
    private String name;
    private Integer age;

    public Employee() {
    }

    public Employee(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public Integer getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(Integer age) {
        this.age = age;
    }

    public String toString() {
        return "Employee{name = " + name + ", age = " + age + "}";
    }
}
public class Demo13 {
    public static void main(String[] args) {
        //题目13：怎样使用map和reduce方法数一数流中有多少个Employee呢？
        ArrayList<Employee> list = new ArrayList<>();
        list.add(new Employee("张三",22));
        list.add(new Employee("李四",23));
        list.add(new Employee("王五",24));
        list.add(new Employee("赵六",22));
        Integer reduce = list.stream().map(s -> 1).reduce(0, (i1, i2) -> i1 + i2);
        System.out.println(reduce);
    }
}
